vpath %.hpp inc:libinc
vpath %.cpp src
vpath %.a lib
vpath %.exe bin
vpath %.so bin
vpath %.o obj

CPPFLAGS = -Wall -std=c++17 -DWIN32 -Iinc -Ilibinc
LDFLAGS = -Llib -static-libgcc -static-libstdc++ 

CLANGFLAGS = -std=c++17 --target=aarch64-linux-android21 -march=armv8-a -fPIC -O3 \
	-DANDROID_ENABLED -DUNIX_ENABLED -DNDEBUG -Iinc

./dep/%.d: %.cpp
	g++ -MM $(CPPFLAGS) $< -o $@ 

%.o: %.cpp
	g++ -c $< -o ./obj/$@ $(CPPFLAGS)

debug: CPPFLAGS += -g
debug: build
release: build

build: libgltfhandler.a 
unit_test: debug unittest.exe

clean:
	rm -f ./obj/*.o

GLTFHANDLER_OBJS := glbReader.o
libgltfhandler.a: $(GLTFHANDLER_OBJS)
	ar rcs ./lib/$@ $(addprefix ./obj/, $(GLTFHANDLER_OBJS))

UNITTEST_OBJS := unittest.o
UNITTEST_A := libgltfhandler.a
unittest.exe: $(UNITTEST_OBJS) $(UNITTEST_A)
	g++ $(addprefix ./obj/, $(UNITTEST_OBJS)) $(addprefix ./bin/, $(UNITTEST_SO)) $(addprefix ./lib/, $(UNITTEST_A)) -o ./bin/$@ $(CPPFLAGS) $(LDFLAGS)

SRCS := $(notdir $(shell find ./src -name "*.cpp" ) ) 
include $(SRCS:%.cpp=./dep/%.d)
